package com.hl.qzzpbackend.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.hl.qzzpbackend.common.BaseResponse;
import com.hl.qzzpbackend.common.ResultUtils;
import com.hl.qzzpbackend.model.dto.application.ApplicationAddRequest;
import com.hl.qzzpbackend.model.dto.application.ApplicationQueryRequest;
import com.hl.qzzpbackend.model.dto.application.ApplicationUpdateStatusRequest;
import com.hl.qzzpbackend.model.vo.ApplicationVO;
import com.hl.qzzpbackend.service.ApplicationService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.validation.Valid;


/**
 * 职位申请接口
 *
 * @author helong
 */
@Slf4j
@Api(tags = "职位申请接口")
@RestController
@RequestMapping("/application")
public class ApplicationController {

    @Resource
    private ApplicationService applicationService;

    // 新增职位申请
    @ApiOperation(value = "新增职位申请")
    @RequestMapping(value = "/add",method = RequestMethod.POST)
    public BaseResponse<Boolean> applicationAdd(@Valid @RequestBody ApplicationAddRequest applicationAddRequest){
        if(log.isInfoEnabled()){
            log.info("新增职位申请：{}",applicationAddRequest);
        }
        boolean result = applicationService.applicationAdd(applicationAddRequest);
        return ResultUtils.success(result);
    }

    // 更新职位申请状态
    @ApiOperation(value = "更新职位申请状态")
    @RequestMapping(value = "/updateStatus",method = RequestMethod.POST)
    public BaseResponse<Boolean> applicationUpdateStatus(@Valid @RequestBody ApplicationUpdateStatusRequest applicationUpdateStatusRequest){
        if(log.isInfoEnabled()){
            log.info("更新职位申请状态：{}",applicationUpdateStatusRequest);
        }
        boolean result = applicationService.applicationUpdateStatus(applicationUpdateStatusRequest);
        return ResultUtils.success(result);
    }

    // 筛选简历
    @ApiOperation(value = "筛选简历")
    @RequestMapping(value = "/screenResume",method = RequestMethod.POST)
    public BaseResponse<Page<ApplicationVO>> applicationScreenResume(@RequestBody ApplicationQueryRequest applicationQueryRequest){
        if(log.isInfoEnabled()){
            log.info("筛选简历：{}",applicationQueryRequest);
        }
        Page<ApplicationVO> page = applicationService.applicationScreenResume(applicationQueryRequest);
        return ResultUtils.success(page);
    }


}
